#ifndef _ABSTRACTHTTPREQUESTHANDLER_HPP_
#define _ABSTRACTHTTPREQUESTHANDLER_HPP_

#include "jhdefs.hpp"
#include "net/HTTPRequestHandler.hpp"
#include "net/HTTPResponse.hpp"
#include "net/HTTPServerRequest.hpp"
#include "net/HTTPServerResponse.hpp"

NET_NAMESPACE_BEGIN

class CHTMLForm;
class CAbstractHTTPRequestHandler : public CHTTPRequestHandler
{
public:
	CAbstractHTTPRequestHandler();
	virtual ~CAbstractHTTPRequestHandler();

	void handleRequest(CHTTPServerRequest& request, CHTTPServerResponse& response);
	CHTTPServerRequest& request();
	CHTTPServerResponse& response();
	CHTMLForm& form();
	void sendErrorResponse(CHTTPResponse::HTTPStatus status, const std::string& message);

protected:
	virtual void run() = 0;
	virtual bool authenticate();

private:
	CHTTPServerRequest*  m_pRequest;
	CHTTPServerResponse* m_pResponse;
	CHTMLForm*           m_pForm;
};

NET_NAMESPACE_END

#endif
